
<!--活动-->
<template>
  <div class="all bg1">
    
    <!-- 无数据 -->
    <VTips text="暂无活动" v-if="!datas.length"></VTips>

    <!-- 列表 -->
    <list class="all">
      <refresh class="refresh" :display="isRefresh ? 'show' : 'hide'" @refresh="httpActivitys">
        <loading-indicator class="load text2"></loading-indicator>
      </refresh>
      <cell v-for="(item, index) in datas" v-bind:key="index">
        <div class="cell">
          <div class="title">
            <text class="font32 text2 all">{{item.activityContent}}</text>

            <text class="font24 no-t1" v-if="item.expireType == 'FOREVER'">{{T('长期有效')}}</text>
            <text class="font24 no-t1" v-else-if="item.activityStates == 'NOT_START'">{{T('即将开始')}}</text>
            <text class="font24 no-t1" v-else-if="item.activityStates == 'END'">{{T('已结束')}}</text>
          </div>
          <LImage class="img" :src="item.imageUrl" @click="cellClick(item)"></LImage>

          <div :class="['line', (index == datas.length - 1 ) ? '' : 'bg4']"></div>
        </div>
      </cell>
    </list>
  </div>
</template>

<style src="@/_css/style.css" ></style>
<style scoped>
/*********************** 列表*/
.cell {
  padding-top: 30px;
  padding-left: 20px;
  padding-right: 20px;
}
.title {
  flex-direction: row;
  align-items: center;
  padding-left: 20px;
  padding-right: 16px;

  margin-bottom: 20px;
}
.line {
  height: 1px;
  margin-top: 50px;
}
.img {
  width: 710px;
  height: 200px;
  border-radius: 24px;
}

/*********************** 刷新*/
.refresh {
  width: 750;
  flex-direction: row;
  justify-content: center;
}
.load {
  height: 40px;
  width: 40px;
}
</style>

<script>

//组件
import VTips from "@/_public/VTips";

//功能
import jnavigator from "@/_js/navigator";
import jmodal from "@/_js/modal";
import jconfig from "@/_js/config";
import jhttps from "@/_js/https"; ;
import jdebug from "@/_js/debug"; ;

const weexFunction = weex.requireModule("WeexFunction");

import I18N from "@/_i18n/i18n";
var T = I18N.t;

weexFunction.setTitle(T('活动中心'));

//关于界面
export default {
  
  components: {
    VTips,
  },

  data() {
    return {
      T:T,
      Config:jconfig,
      isRefresh:false, //turn 刷新

      datas:[],
    };
  },

  created(){
    this.httpActivitys();
  },
  
  methods: {
    
    /********************************** HTTP*/
    //活动列表-刷新
    httpActivitys() {
      if (this.isRefresh) return;
      this.isRefresh = true;

      var param = {};
      jhttps.post("activity/queryActivityCenterList",param,true,(data) => {
          this.isRefresh = false;
          if (data.status == 200) {
            data = data.data;
            this.datas = data.activityList;
          } else {
            jmodal.toast(data.msg);
          }
      });
    },

    /********************************** 点击事件*/
    //cell点击
    cellClick(item){
      if (item.activityStates == 'NOT_START') {
        jmodal.toast(T('活动未开始'));
        return;
      }
      
      if (item.pageType == 'OUT_LINK') {
        weexFunction.showWebUrl(item.activityUrl);
      } else if (item.pageType == 'DIALOG') {

        var param = {'activityId':item.activityId};
        jnavigator.openDialog(item.activityUrl, param);
      } else if (item.pageType == 'PAGE') {
        var param = {'activityId':item.activityId};
        var nav = (item.activityUrl == 'task/TaskNew') ? {'navColor':'#3232F3'} : undefined;
        jnavigator.open('',item.activityUrl, param, nav);
      } 
    },
  }
};

</script>
